package com.hf.action;


import java.sql.Timestamp;
import java.util.*;

import org.hibernate.Query;

import tool.TimeTool;
import tool.UploadImg;

import com.base.bean.*;
import com.base.dao.*;
import com.base.service.*;
import com.base.service.session.SessionService;

import com.base.domain.*;

/**
 * 客户共享管理
 * @author Administrator
 *
 */

public class ShareClientAction extends BaseAction{
	private Integer cid,type,oppType;	

	private String state;	// "": default    a:share

	
	public ShareClientAction() {

	}


	public static void main(String[] args){
		ShareClientAction a=new ShareClientAction();
		a.execute();
	}
	
	public String execute(){
		this.state = (this.state==null?"":this.state);
		this.tip="";
		this.openId=(this.openId==null?"":this.openId);
		this.oppType=(this.oppType==null?0:this.oppType);
		this.cid=(this.cid==null?0:this.cid);
		ClientBase cb0 =  null;
		Integer owner0= null;
		if(!this.cid.equals(0)){
			cb0 = ClientService.getInstance().getClientBaseDao().findByHql("from ClientBase cb where cb.cid="+this.cid).get(0);
			owner0 = cb0.getOwner();
		}
		
//		this.openId="olWUvtyjC1_f5R47wW3NxOD1yS40";
//		this.state="a";
//		this.cid=37530;
		
		if(!this.openId.equals("") && this.state.equals("a"))
			return "begin";
		else if(!this.openId.equals("") && this.state.equals("b")){
			
//			SessionService ss = SessionService.getInstance();
//			User u =UserService.getInstance().getByOpenId(this.openId);
//			int sid = ss.createSession(u.getUid(), 0);
//			ss.createMsgBySid(sid, u.getUid(), "客户共享请求发起成功，请通知对方处理", "content", "url");
//			ss.createMsgBySid(sid, owner0, "待处理客户共享，请通知对方处理", "content", "url");
			
			// 还要添加 被呼叫方
			
			return SUCCESS;
			
		}else{
			return ERROR;
		}

		
	}



	public Integer getCid() {
		return cid;
	}



	public void setCid(Integer cid) {
		this.cid = cid;
	}



	public Integer getType() {
		return type;
	}



	public void setType(Integer type) {
		this.type = type;
	}



	public Integer getOppType() {
		return oppType;
	}



	public void setOppType(Integer oppType) {
		this.oppType = oppType;
	}



	public String getState() {
		return state;
	}



	public void setState(String state) {
		this.state = state;
	}
	

	
	
	

}
